#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<unordered_map>
using namespace std;
const int N = 1e6 + 10;
int a[N];
int main()
{
    int T, n;
    cin >> T;
    while (T--)
    {
        cin >> n;
        for (int i = 1; i <= n; i++)
        {
            cin >> a[i];
        }
        int left = 1;
        int right = 1;
        unordered_map<int, int> as;
        int ret = 0;
        while (right <= n)
        {
            as[a[right]]++;
            while (as[a[right]] > 1)
            {
                as[a[left]]--;
                left++;
            }
            ret = max(ret, right - left + 1);
            right++;
        }
        cout << ret << endl;
    }
    return 0;
}